package br.com.kallango.server.protocolo;

import java.nio.ByteBuffer;

import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolEncoderAdapter;
import org.apache.mina.filter.codec.ProtocolEncoderOutput;

public class CodificaProtocolo extends ProtocolEncoderAdapter {

	@Override
	public void encode(IoSession arg0, Object object, ProtocolEncoderOutput out) {

		byte[] bytes = (byte[]) object;
		ByteBuffer buffer = ByteBuffer.allocate(bytes.length);
		buffer.put(bytes);
		buffer.flip();
		out.write(buffer);
	}

}
